/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mia;

import java.util.ArrayList;

/**
 *
 * @author Greg Jarzab <greg.jarzab@gmail.com>
 */
public class Main
{

    private static void usage()
    {
        System.out.println( "Usage: mia [DB URL] [ Query File path ] [ Thread count ]" );
        System.out.println( "Example:\n mia jdbc:derby://localhost:1527/C:\\Database\\Medical C:\\queries.xml 3" );
    }
    /**
     * @param args the command line arguments
     */
    public static void main( String[] args )
    {
        if( args.length < 3 )
        {
            usage();
            System.exit( -1 );
        }

        QueryTester tester = new QueryTester( args[0] );
        QueryLoader loader = new QueryLoader();

        if( !loader.LoadQueries( args[1] ) )
        {
            System.out.println( "Check query file and try again" );
            System.exit( -2 );
        }

        for( Query q : loader.GetQueries() )
        {
            tester.AddQuery( q );
        }

        ArrayList<Integer> queryOrder = new ArrayList<Integer>();

        queryOrder.add( 0 );
        queryOrder.add( 1 );
        queryOrder.add( 0 );
        queryOrder.add( 3 );
        queryOrder.add( 4 );
        queryOrder.add( 1 );
        queryOrder.add( 12 );
        queryOrder.add( 9 );
        queryOrder.add( 1 );
        queryOrder.add( 6 );
        queryOrder.add( 3 );
        queryOrder.add( 4 );
        queryOrder.add( 1 );
        queryOrder.add( 10 );
        tester.SetQueryOrder( queryOrder );

        tester.RunTests( Integer.parseInt( args[2] ), false );
    }
}
